<template>
  <div>
    <div class="addbut"></div>

    <div v-loading="loading.table">
      <el-table :data="constantList"  style="width: 100%;font-size:12px" border highlight-current-row>
        <el-table-column type="index" label="序号" align="center"></el-table-column>
        <el-table-column prop="key" label="key" align="center"></el-table-column>
        <el-table-column prop="name" label="常量名称" align="center"></el-table-column>
        <el-table-column prop="value" label="常量值" align="center"></el-table-column>
        <el-table-column prop="createTime" label="创建时间" align="center"></el-table-column>
        <el-table-column prop="updateTime" label="更新时间"  align="center"></el-table-column>
        <el-table-column  label="操作" min-width="50" align="center">
          <template slot-scope="scope">
            <i class="el-icon-edit el-icon--right"></i>
            <el-button type="text" @click="toEdit(scope.row)">编辑</el-button>
          </template>
        </el-table-column>
      </el-table>

      <!--<el-pagination @current-change="paginationChangeFn" background layout="prev, pager, next" :page-count="pagination.pageCount"> </el-pagination>-->
    </div>
  </div>
</template>

<script>
    export default {
        name:'ConstantList',
        data() {
            return {
                constantList:[],
                loading: {table: false},
            };
        },
        methods: {
            // paginationChangeFn(currentPage) {
            //     this.pagination.currentPage = currentPage;
            //     this.loadGrid();
            // },
            loadGrid() {
                this.loading.table=true;
                // let params  = {
                //     currentPage: this.pagination.currentPage,
                // };
                this.$api.getSysConstantList().then(response=>{
                    this.loading.table = false;
                    let result = response.data;
                    if(result.code==0){
                        this.constantList = result.data;;
                    }
                    // this.pagination.pageCount = result.data.totalPage;
                });
            },
            toEdit(row){
                let params = {'key':row.key};
                this.$router.push({name:'ConstantEditor',params:params});
            }
        },
        created() {
            this.loadGrid();
        }
    };
</script>

<style lang="less" scoped>
  .addbut{
    margin-bottom:20px;
  }
  #statusSwitch {
    display: block;
  }
  .el-icon--right{
    color:#4db3ff;
    margin-left:15px
  }
  #queryDiv {
    margin-bottom: 20px;
    .queryInput {
      width:200px;
      margin-right:20px
    }
    .search{
      margin-left:20px
    }
    .btn-add{
      margin-left: 150px;
    }
  }
  .imgsrc{
    margin-left:20px;
    margin-top:10px;
  }
  .el-table .cell {
    white-space: pre-line;
  }

</style>
